/*
	flad : Copyright 2010 Dale J Williams

	Licensed under the Apache License, Version 2.0 (the "License");
	you may not use this file except in compliance with the License.
	You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
*/
package lads.flad.screens {
	
	import lads.flad.display.Widget;
	import lads.flad.GameCore;
	import lads.flad.screens.ScreenManager;
	import flash.events.Event;
	
	/**
	 * GameScreen: A single full-screen instance.
	 * @author Dale J Williams
	 * @version 1.2
	 */
	public class GameScreen extends Widget {
		
		static public const ADDED	:String = "screen added";
		static public const REMOVED	:String = "screen removed";
		
		private var _manager	:ScreenManager;
		private var _core		:GameCore;
		
		public function GameScreen($name:String) { 
			name = $name;
		}
		
		/// animate the screen in
		public function animIn():void {
			animInComplete();
		}		
		
		/// implicitly called, should occur when the screen has finished animating in
		protected function animInComplete():void {
			dispatchEvent(new Event(ADDED));
		}
		
		/// animate the screen out
		public function animOut():void {
			animOutComplete();
		}
		
		/// implicitly called, should occur when the screen has finished animating out
		protected function animOutComplete():void {
			dispatchEvent(new Event(REMOVED));
		}
		
		/// a reference to the screen manager that is managing this screen
		public function get manager():ScreenManager { return _manager; }		
		public function set manager(value:ScreenManager):void {
			_manager = value;
			_core = _manager ? _manager.core : null;
		}
		
		public function get core():GameCore { return _core; }		
		public function set core(value:GameCore):void {
			_core = value;
		}
				
	}

}